from turtle import title
from django.db.models import QuerySet, Q

from server.apps.main.models import Todolist


def list_published() -> QuerySet[Todolist]:
    """Returns all Todolist that are ready to be published."""
    return Todolist.objects.all().order_by("-id")

def find(text:str) -> QuerySet[Todolist]:
    return Todolist.objects.filter(Q(title__contains=text)| Q(description__contains=text))

def get_title(id:int) -> str:
    return Todolist.objects.filter(id=id).values_list('title')

def get_description(id:int)-> str:
    return Todolist.objects.filter(id=id).values_list('description')


def find_by_id(id:int)-> QuerySet[Todolist]:
    return Todolist.objects.filter(id=id)